package com.design.cjm.behavioral.memento.example1;

/**
 * @Author: Jie Ming Chen
 * @Date: 2018/9/24
 * @Version 1.0
 */
public class TestApp {

    public static void main(String[] args) {

        // 初始状态属性为“on”
        Originator o = new Originator();
        o.setState("on");

        o.show();

        Caretaker c = new Caretaker();
        // 保存状态，封装细节
        c.setMemento(o.createMemento());

        // 状态发生了变化
        o.setState("off");
        o.show();

        // 恢复原初始状态
        o.setMemento(c.getMemento());
        o.show();
    }
}
